package com.ruoyi.hr.service.impl.welfare.welfarecalculationconfig;

import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.hr.domain.welfare.welfarecalculationconfig.CcdBeneItemType;
import com.ruoyi.hr.domain.welfare.welfarecalculationconfig.CcdBenefitbase;
import com.ruoyi.hr.mapper.welfare.welfarecalculationconfig.CcdBenefitbaseMapper;
import com.ruoyi.hr.service.welfare.welfarecalculationconfig.ICcdBenefitbaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.List;

/**
 * 福利基数Service业务层处理
 *
 * @author zeo
 * @date 2019-12-26
 */
@Service
public class CcdBenefitbaseServiceImpl implements ICcdBenefitbaseService {
    @Autowired
    private CcdBenefitbaseMapper ccdBenefitbaseMapper;

    /**
     * 查询福利基数
     *
     * @param id 福利基数ID
     * @return 福利基数
     */
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public CcdBenefitbase selectCcdBenefitbaseById(Long id) {
        return ccdBenefitbaseMapper.selectCcdBenefitbaseById(id);
    }

    /**
     * 查询福利基数列表
     *
     * @param ccdBenefitbase 福利基数
     * @return 福利基数
     */
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public List<CcdBenefitbase> selectCcdBenefitbaseList(CcdBenefitbase ccdBenefitbase) {
        return ccdBenefitbaseMapper.selectCcdBenefitbaseList(ccdBenefitbase);
    }

    /**
     * 新增福利基数
     *
     * @param ccdBenefitbase 福利基数
     * @return 结果
     */
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int insertCcdBenefitbase(CcdBenefitbase ccdBenefitbase) {
        return ccdBenefitbaseMapper.insertCcdBenefitbase(ccdBenefitbase);
    }

    /**
     * 修改福利基数
     *
     * @param ccdBenefitbase 福利基数
     * @return 结果
     */
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int updateCcdBenefitbase(CcdBenefitbase ccdBenefitbase) {
        return ccdBenefitbaseMapper.updateCcdBenefitbase(ccdBenefitbase);
    }

    /**
     * 删除福利基数对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int deleteCcdBenefitbaseByIds(String ids) {
        int num = 0;
        try {
            ccdBenefitbaseMapper.deleteCcdBenefitbaseByIds(Convert.toStrArray(ids));
            num = 1;
        } catch (Exception e) {

        }
        return num;
    }

    /**
     * 删除福利基数信息
     *
     * @param id 福利基数ID
     * @return 结果
     */
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int deleteCcdBenefitbaseById(Long id) {
        return ccdBenefitbaseMapper.deleteCcdBenefitbaseById(id);
    }

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public List<CcdBenefitbase> findAll() {
        return ccdBenefitbaseMapper.findAll();
    }

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public List<CcdBeneItemType> findCcdBeneItemType() {
        return ccdBenefitbaseMapper.findCcdBeneItemType();
    }
}
